1. Field of the Invention
This invention relates in general to a computer programming, and more particularly to a method, system and program storage device for preventing a real-time application from running out of free threads when the real-time application receives a device interface request.
2. Description of Related Art
In a highly competitive market environment, “time to market with superior quality” is the key focus in developing a new product. For a well-established development team with years of experience in software development, the reusability of existing software is the very key to achieving the goals of delivering a new product in the most efficient way with superior quality. Given the stiff competition in the market environment, what a new product is required to do is constantly increasing and how much it is allowed to cost is reducing. For a software product development, the demanding requirements and pressure of lowering cost are translated into the need for the reuse of existing software functions in various hardware platforms. One of the focus items to achieve high software reusability is to develop the software functions with the encapsulation of a platform they are operating upon. The platform includes the actual hardware and the operating systems.
One key consideration in selecting a platform for a product is whether the software can best perform in privileged mode or user mode. In contrast, kernel mode or privileged mode is the mode in which the operating system kernel runs. Code running in this mode has unlimited access to the system memory and external devices.
The traditional thinking is software can best perform in privileged mode. However, given the advancing technology in hardware platform development, operating in user mode may be a much better choice given different product requirements. The built-in protection provided by all modern operating systems for a software running in user mode, the ease of managing a program in a user mode, and the improved system stability with new software functions isolated from kernel are significant benefits of implementing a software project in user mode.
For a software product family to maintain high reusability across a range of products that may be operating in various platforms, a consistent device interface is a key for the software functions it provides to be invoked consistently. A software product consists of a set of key software components and software applications, which may be implemented as collaborating privileged and user mode applications to provide the functionality intended by the software product. In a user mode implementation of a real-time software application, the software product also provides a user mode device interface using socket interface.
For a real-time user application to run on a particular platform that has a relatively small run-time memory constraints, one design is to create a finite number of threads in a thread pool to handle all incoming device interface requests from other utility programs. The number of threads in a thread pool may be predetermined. Each device interface request to the real-time user application is handled by a thread in the pool that is free, i.e., not busy. Once a request is completed, the thread returns to the free thread pool waiting for the next incoming request.
However, the real-time application can run out of free threads upon the receipt of a new request because there are only a finite number of threads in the pool and because many utility programs can be making device interface requests to the real-time user application at the same time. A typical solution is to increase the number of the free threads in the pool. Unfortunately, the solution causes the real-time application to allocate/demand more from the limited total resource for a condition that is rarely reached. Another typical solution to the same problem is to return an error condition to a utility program to indicate it is temporarily unable to handle such request. A big issue with this error reporting approach is it would cause utility program to implement additional error handling for a temporary resource contention.
A better solution to this problem is needed so the real-time application does not keep increasing its allocation for resource to support more “free” threads and, at the same time, utility programs do not have to implement additional error handling for a temporary unavailability of threads to handle device interface requests.
There is a need for a method, system and program storage device for preventing a real-time application from running out of free threads when the real-time application receives a device interface request.